'''
反转字符串中的单词：
将字符串切分成单词列表，反转每个单词，再合并成字符串
'''

def reverseWords(s: str) -> str:
    # 分割字符串成单词列表
    words = s.split(' ')
    # 反转每个单词
    reversed_words = [word[::-1] for word in words]
    # 用空格连接单词
    return ' '.join(reversed_words)

# 测试用例
def test_reverseWords():
    # 测试用例 1
    s1 = "Let's take LeetCode contest"
    print(f"Test case 1: {reverseWords(s1)}")  # 预期输出: "s'teL ekat edoCteeL tsetnoc"

    # 测试用例 2
    s2 = "Mr Ding"
    print(f"Test case 2: {reverseWords(s2)}")  # 预期输出: "rM gniD"

    # 测试用例 3
    s3 = "Hello World"
    print(f"Test case 3: {reverseWords(s3)}")  # 预期输出: "olleH dlroW"

    # 测试用例 4
    s4 = "a"
    print(f"Test case 4: {reverseWords(s4)}")  # 预期输出: "a"

    # 测试用例 5
    s5 = "The quick brown fox"
    print(f"Test case 5: {reverseWords(s5)}")  # 预期输出: "ehT kciuq nworb xof"

# 运行测试用例
test_reverseWords()